/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ADT;
import Interfaces.StowageLocation;

/**
 *
 * @author markusbaisch
 */
public class StowageLocationImpl implements StowageLocation {
    // Member
    int bay;
    int row;
    int tier;

    // Konstruktor
    private StowageLocationImpl(int bay, int row, int tier) {
        if(bay < 0 || row < 0 || tier < 0 ) throw new IllegalArgumentException("Bay, Row, Tier must be positive");
        this.bay = bay;
        this.row = row;
        this.tier = tier;
    }

    public static StowageLocation valueOf(int bay, int row, int tier) {
        return new StowageLocationImpl( bay, row, tier );
    }

    @Override
    public int bay() {
        return bay;
    }

    @Override
    public int row() {
        return row;
    }

    @Override
    public int tier() {
        return tier;
    }

    @Override
    public boolean isNull() {
        return false;
    }

    @Override
    public int hashCode() {
        return Values.hashDouble( bay ) + (2*Values.hashDouble( row )) + (3*Values.hashDouble( tier ));
    }

    @Override
    public boolean equals( Object o ) {
        if (this == o) return true;
        if (!(o instanceof StowageLocation)) return false;
        StowageLocation tmp = (StowageLocation)o;
        return ( tmp.bay()  == bay  && tmp.tier() == tier && tmp.row()  == row );
    }
}
